package util

import (
	"net/http"
	"io/ioutil"
	"bytes"
	"log"
)

func CurlGet(url string) string{
	resp, err:= http.Get(url)
	if err!=nil{
		log.Print(err)
	}
	defer resp.Body.Close()
	body, _ := ioutil.ReadAll(resp.Body)
	return string(body)
}


func PostJson(jsonStr string,url string) string{
	req, err := http.NewRequest("POST", url, bytes.NewBuffer([]byte(jsonStr)))
	req.Header.Set("Content-Type", "application/json")
	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	body, _ := ioutil.ReadAll(resp.Body)
	return string(body)
}